home *** CD-ROM | disk | FTP | other *** search
- /* --------------------------------------------
- patch InvertRect.c
-
- THINK C "Set Project Type..." settings:
- code resource, type 'OAPn', ID 1001,
- custom header, preloaded and locked,
- file type 'rsrc', file creator 'RSED'.
- --------------------------------------------
- */
- #include <Traps.h>
- #include "defs.h"
-
- void main(void);
- void My_InverRect( void );
-
- /* -------- global variables ---------- */
- long Old_InverRect = NIL;
-
- void main(void)
- {
- long save_A4;
-
- asm {
- move.L A4, save_A4
- LEA main, A4
- }
-
- if (Old_InverRect == NIL)
- {
- Old_InverRect = GetToolTrapAddress(
- _InverRect );
- SetToolTrapAddress( (long)My_InverRect,
- _InverRect );
- }
-
- asm {
- move.L save_A4, A4
- }
- }
-
-
- /* ---------------------------------------------
- My_InverRect Watch for the insertion point
- to be drawn, and record its
- horizontal coordinate.
- ---------------------------------------------
- */
- void My_InverRect( void )
- {
- Rect *rect;
- Wrap_info **info;
-
- asm {
- movem.L a0-a5/d0-d7, -(SP); save registers
- LEA main, A4 ; access to globals
- move.L 8(A6), rect
- }
-
- if ( rect->right - rect->left == 1 )
- {
- info = (Wrap_info **)
- GetResource('OAP1', 128);
- (**info).last_insertion_point = rect->right;
- }
-
- /*
- The following code restores all registers and
- jumps to the saved trap address. It relies
- on there being at least 4 bytes on the stack
- frame, which can be trashed by moving the
- saved A6 down. Bear in mind that THINK C will
- insert UNLK A6 and RTS instructions afterward.
- */
- asm {
- move.L (A6), -4(A6)
- move.L Old_InverRect, (A6)
- subQ #4, A6
- movem.L (SP)+, A0-A5/D0-D7
- }
- }
-